﻿package org.hsl.haxe;
/**
 * A signal contains data that can be used by listeners. When a dispatcher calls the dispatch method of a signaler, the
 * signaler creates a sends a signal to the slot list, and bubbles it.
 */
class Signal<D> {
	/**
	 * The dispatcher that is currently dispatching this signal. This dispatcher might be the initial dispatcher for this signal,
	 * but could also be dispatching this signal in result of bubbling.
	 */
	public var currentDispatcher(default, null):IDispatcher;
	/**
	 * The data associated with this signal.
	 */
	public var data(default, null):D;
	/**
	 * The dispatcher that initially dispatched this signal.
	 */
	public var initialDispatcher(default, null):IDispatcher;
	/**
	 * Creates a new signal.
	 */
	public function new(data:D, currentDispatcher:IDispatcher, initialDispatcher:IDispatcher):Void {
		this.data = data;
		this.currentDispatcher = currentDispatcher;
		this.initialDispatcher = initialDispatcher;
	}
	private function toString():String {
		return "[Signal data=" + Std.string(data) + " currentDispatcher=" + Std.string(currentDispatcher) + " initialDispatcher=" + Std.string(initialDispatcher) + "]";
	}
}